def game_to_dic(game):
    rawGame = {
        'id': game.key().id(),
        'name': game.name,
        'players': players_to_dic(game.players())
    }
    return rawGame

def games_to_dic(games):
    rawGames = []
    for game in games:
        rawGames.append(game_to_dic(game))

    return rawGames

def players_to_dic(players):
    rawPlayers = []
    for player in players:
        rawPlayers.append(player_to_dic(player))

    return rawPlayers

def player_to_dic(player):
    rawPlayer = {
        'info': player_info_to_dic(player.info),
        'is_ready': player.isReady
    }
    return rawPlayer

def player_info_to_dic(playerInfo):
    rawPlayerInfo = {
        'id': playerInfo.key().id(),
        'name': playerInfo.name,
        'role': playerInfo.role,
    }
    return rawPlayerInfo